package ch.zhaw.swp1.view.panels;

import java.awt.FlowLayout;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import ch.zhaw.swp1.view.panels.compose.EmailComposePanel;
import ch.zhaw.swp1.view.panels.compose.GenericComposePanel;
import ch.zhaw.swp1.view.panels.compose.MMSComposePanel;
import ch.zhaw.swp1.view.panels.compose.PrintComposePanel;
import ch.zhaw.swp1.view.panels.compose.SMSComposePanel;

/**
 * Abstract class to compose a message
 * @author Martin Trutmann
 */
public class MessageComposePanel extends JPanel {
	

	/**
	 * Default version
	 */
	private static final long serialVersionUID = 1L;
	JTabbedPane tabPane = new JTabbedPane();
	private SMSComposePanel smsPanel = new SMSComposePanel();
	private EmailComposePanel emailPanel = new EmailComposePanel();
	private MMSComposePanel mmsPanel = new MMSComposePanel();
	private PrintComposePanel printPanel = new PrintComposePanel();
	
	/************************************************************************************/
	// Constructors
	/*----------------------------------------------------------------------------------*/
	/**
	 * Default Constructor
	 */
	public MessageComposePanel(){
		super();
		init();
		layoutComponents();
	}
	
	/************************************************************************************/
	// Methods
	/*----------------------------------------------------------------------------------*/
	/**
	 * Initialization
	 */
	private void init(){
		setLayout(new FlowLayout());
	}
	
	/**
	 * Lay out components on screen
	 */
	private void layoutComponents(){
		tabPane.addTab("SMS", smsPanel);
		tabPane.addTab("MMS", mmsPanel);
		tabPane.addTab("E-Mail", emailPanel);
		tabPane.addTab("Print", printPanel);
		add(tabPane);
	}
	
	/************************************************************************************/
	// Getter/Setter
	/*----------------------------------------------------------------------------------*/
	public String getMessageText(){
		GenericComposePanel currentPanel = getCurrentPane();
		return currentPanel.getMessageText();
	}
	public GenericComposePanel getCurrentPane() {
		return (GenericComposePanel) tabPane.getSelectedComponent();
	}
}
